import request from "@/utils/request";
import type { LoginResponse, GetUserInfoResponse } from "./model/loginModel";

enum Api {
  loginUrl = "/admin/acl/index/login",
  logoutUrl = "/admin/acl/index/logout",
  getUserInfoUrl = "/admin/acl/index/info",
}

/**
 * 登录
 * @param username 用户名
 * @param password 密码
 * @returns LoginResponse
 */
export const loginApi = (username: string, password: string) => {
  return request.post<any, LoginResponse>(Api.loginUrl, {
    username,
    password,
  });
};

/**
 * 退出登录
 * @returns null
 */
export const logoutApi = () => {
  return request.post<any, null>(Api.logoutUrl);
};

/**
 * 获取用户数据
 * @returns GetUserInfoResponse
 */
export const getUserInfoApi = () => {
  return request.get<any, GetUserInfoResponse>(Api.getUserInfoUrl);
};
